﻿<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <title>考勤报表</title>
    <script type="text/javascript" src="./js/jquery-2.2.4.min.js"></script>
    <link href="./css/animate.css" rel="stylesheet">
    <script type="text/javascript" src="./component/layer-v3.0.3/layer/layer.js"></script>
    <link rel="stylesheet" href="./component/font-awesome-4.7.0/css/font-awesome.min.css">
    <link href="./css/default.css" rel="stylesheet">
    <script src="../assets/js/m.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script src="//cdn.bootcss.com/eruda/1.4.2/eruda.min.js"></script>
    <script src="../assets/js/md5.min.js"></script>
    <script>
        eruda.init();
    </script>
    <link type="text/css" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui-for-work.min.css" rel="stylesheet" />
    <style type="text/css">
        body {
            background-color: #f8f8f8
        }

        .rptItem {
            margin-bottom: 8px;
        }

        .btn-k1 {
            background-color: deepskyblue;
        }

        .btn-k2 {
            background-color: aquamarine;
        }

        .btn-k3 {
            background-color: rosybrown;
        }

        .btn-k4 {
            background-color: mediumpurple;
        }

        .btn-k5 {
            background-color: mediumslateblue;
        }

        .btn-k6 {
            background-color: rebeccapurple;
        }

        .btn-k7 {
            background-color: slateblue;
        }
    </style>

    <script>
        var showFillWindow = function (title,url) {
            var index = layer.open({
                type: 2,
                title: title,
                content: url,
                area: ['320px', '195px'],
                maxmin: true
            });

            layer.full(index);
        }
        $(function () {
            var rptMap = [{
                "Id": "rpt01",
                "url": "http://oabb.os.erp-km.cn/demo/reportJsp/mb-preview1.jsp?rpx=%2Foa_ehr_report1-moblie.rpx&rpxHome=E%3A%2FOA_report_test%2Fehr&dfxHome=&arg=E%3A%2FOA_report_test%2Fehr%2Foa_ehr_report1-moblie_arg.rpx",
                "title": "年假查询",
                "class": "btn-k1"
            }, {
                "Id": "rpt02",
                "url": "http://oabb.os.erp-km.cn/demo/reportJsp/mb-preview2.jsp?rpx=%2Foa_ehr_report2-moblie.rpx&rpxHome=E%3A%2FOA_report_test%2Fehr&dfxHome=&arg=E%3A%2FOA_report_test%2Fehr%2Foa_ehr_report2-moblie_arg.rpx",
                "title": "请假查询",
                "class": "btn-k2"
            }, {
                "Id": "rpt03",
                "url": "http://oabb.os.erp-km.cn/demo/reportJsp/mb-preview3.jsp?rpx=%2Foa_ehr_report3-moblie.rpx&rpxHome=E%3A%2FOA_report_test%2Fehr&dfxHome=&arg=E%3A%2FOA_report_test%2Fehr%2Foa_ehr_report3-moblie_arg.rpx",
                "title": "考勤结果查询",
                "class": "btn-k3"
            }, {
                "Id": "rpt04",
                "url": "http://oabb.os.erp-km.cn/demo/reportJsp/mb-preview4.jsp?rpx=%2Foa_ehr_report4-moblie.rpx&rpxHome=E%3A%2FOA_report_test%2Fehr&dfxHome=&arg=E%3A%2FOA_report_test%2Fehr%2Foa_ehr_report4-moblie_arg.rpx",
                "title": "公差查询",
                "class": "btn-k4"
            }, {
                "Id": "rpt05",
                "url": "http://oabb.os.erp-km.cn/demo/reportJsp/mb-preview5.jsp?rpx=%2Foa_ehr_report5-moblie.rpx&rpxHome=E%3A%2FOA_report_test%2Fehr&dfxHome=&arg=E%3A%2FOA_report_test%2Fehr%2Foa_ehr_report5-moblie_arg.rpx",
                "title": "加班查询",
                "class": "btn-k5"
            }, {
                "Id": "rpt06",
                "url": "http://oabb.os.erp-km.cn/demo/reportJsp/mb-preview6.jsp?rpx=%2Foa_ehr_report6-moblie.rpx&rpxHome=E%3A%2FOA_report_test%2Fehr&dfxHome=&arg=E%3A%2FOA_report_test%2Fehr%2Foa_ehr_report6-moblie_arg.rpx",
                "title": "补签查询",
                "class": "btn-k6"
            }, {
                "Id": "rpt07",
                "url": "http://oabb.os.erp-km.cn/demo/reportJsp/mb-preview7.jsp?rpx=%2Foa_ehr_report7-moblie.rpx&rpxHome=E%3A%2FOA_report_test%2Fehr&dfxHome=&arg=E%3A%2FOA_report_test%2Fehr%2Foa_ehr_report7-moblie_arg.rpx",
                "title": "打卡记录查询",
                "class": "btn-k7"
            }];

            //获取地址栏参数
            var getUrlParam = function (name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]);
                return null;
            };

            var code = getUrlParam("code") || "";
            var config = getUrlParam("state") || "";

            new window.Kmer({
                "AppRootPath": "",
                "CurrentUrl": ""
            });


            //注入配置
            var url3 = window.location.href;
            Y.API2("WXBase", "GetConfig", { "url": url3, "wxConfig": config }, function (data) {
                if (data.Success == false) {
                    console.log("WXBase GetConfig失败", data.Message);
                } else {
                    wx.config({
                        //beta: true,// 必须这么写，否则wx.invoke调用形式的jsapi会有问题
                        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                        appId: data.corpId, // 必填，企业微信的corpID
                        timestamp: data.timeStamp, // 必填，生成签名的时间戳
                        nonceStr: data.nonceStr, // 必填，生成签名的随机串
                        signature: data.signature, // 必填，签名，见附录1
                        jsApiList: [
                            "onMenuShareWechat", "onMenuShareAppMessage", "hideOptionMenu", "startWifi", "getConnectedWifi"
                        ]
                        // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
                    });
                }
            });

            //准备微信相关（包括wifi）
            wx.ready(function () {
                // config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中。
                //分享给朋友接口

                /* begin禁用微信分享功能 */
                function onBridgeReady() {
                    WeixinJSBridge.call('hideOptionMenu');
                }

                if (typeof WeixinJSBridge == "undefined") {
                    if (document.addEventListener) {
                        document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
                    } else if (document.attachEvent) {
                        document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                        document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
                    }
                } else {
                    onBridgeReady();
                }
                /* end禁用微信分享功能 */
            });

            Y.API2("WXBase", "GetDbUser", { "Code": code,"wxConfig": config }, function (data) {
                if (data.Success == false) {
                    console.log("GetUser 失败", data.Message);
                } else {
                    console.log("GetUser 成功", data);
                    //用户信息
                    var user = data || null;
                    if (user != null) {
                        for (var i = 0; i < rptMap.length; i++) {
                            var itemData = rptMap[i];
                            var win_url = itemData.url + "&A0190=" + md5(user.UserId).toUpperCase();
                            var html = '<div class="rptItem"><a class="weui-btn ' + itemData.class + '" href="javascript: void(0)" onclick="showFillWindow(\'' + itemData.title + '\',\'' + win_url + '\')">' + itemData.title + '</a><div>';
                            $('#rptList').append(html);
                        }
                    }
                }
            });


        });
    </script>
</head>

<body>
    <div id="rptList" style="margin: 8px;">
    </div>
</body>

</html>